package configs

import (
	"github.com/spf13/cast"
	"lib/mall/v1/helpers"
	"os"
)

type Config struct {
	Debug    bool     `form:"debug"`
	Host     string   `form:"host"`
	Port     string   `form:"port"`
	Database Database `form:"database.go"`
}

var config Config

func init() {
	config = Config{
		Debug:    cast.ToBool(helpers.DefaultValue(os.Getenv("DEBUG"), false)),
		Host:     cast.ToString(helpers.DefaultValue(os.Getenv("HOST"), "0.0.0.0")),
		Port:     cast.ToString(helpers.DefaultValue(os.Getenv("PORT"), 8090)),
		Database: newDatabaseConfig(),
	}
}
func NewConfig() Config {
	return config
}
